package com.liao.starapp.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;

public class GetAssetsData {

    public static String getGridViewText(Context context,String fileName) {
        try {
            InputStream is = context.getAssets().open(fileName);
            int length = is.available();
            byte[] bytes = new byte[length];
            is.read(bytes);
            String s = new String(bytes);
            return s;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static Bitmap getGridViewImg(Context context, String fileName) {
        try {
            InputStream is = context.getAssets().open(fileName);
            return BitmapFactory.decodeStream(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
